<?php
session_start(); 
header('Content-Type:text/html; charset=utf-8');
$pgtitle='在线投稿-'; 
include_once('../youngth/global.php'); 
include("header.php");
if(isset($_POST['submit'])){
	Add_S($_POST);
	$code=$_POST['seccode'];
	if(!ckseccode($code)){echo "<script>alert('验证码错误.');history.go(-1);</script>";exit;}
	$cateid=$_POST['sort'];
	if(getinfo($cateid,pubtype,categories)!='list') showmsg("抱歉，该栏目下不允许添加文章！","");
	$array['essay_title']=$_POST['title'];
	$array['essay_author']=$_POST['author'];
	$array['essay_categoryid']=$cateid;
	$array['essay_content']=$_POST['content'];
	$array['essay_source']=$_POST['source'];
	$array['essay_status']='draft';
	$array['essay_createtime']=time();
	$array['essay_updatetime']=date("Y-m-d H:i:s",time());
	//setcookie("ctitle", $cateid,time()+3600);
	if(inserttable("essay",$array)){
				showmsg("恭喜你，你的稿件投放成功！","");
	}else{
		showmsg("操作失败！");
	}
	
}
//投稿角色权限
$sqlr="select `role_havecategory` from ".tbname('role')." where role_id=".ANY_CONTRIBUTEID.""; 
$resr = $_ANYGLOBAL['db']->query($sqlr);
$rowr= $_ANYGLOBAL['db']->getone($resr);
//echo $rowr['role_havecategory'];
$catearr=explode('|',$rowr['role_havecategory']);
?>
<div id="list" style="border:none;">
<style type="text/css">
#wrapper {width:980px; height:auto; margin:auto;}
#content form tr {margin:10px;}
</style>
<div id="wrapper"> <!--  wrapper begin-->
<?php
//include($filePath."side.php");
?>
<div id="content">
<script type="text/javascript" charset="utf-8" src="../youngth/common/js/jquery.min.js"></script>
  <script type="text/javascript" charset="utf-8" src="../youngth/common/editor/kindeditor.js"></script>
  <script type="text/javascript">
    KE.show({
        id : 'content_editor',
		resizeMode : 1,
        cssPath : '../youngth/common/editor/index.css',
			//allowFileManager:true,
		skinType:'any',
        items : [
				'source', 'fullscreen', 'undo', 'redo','fontname', 'fontsize', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline',
				'removeformat', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
				'insertunorderedlist', 'emoticons', 'image', 'flash', 'media','file_manager','hr','link'
				]
    });

		$(function(){
	$("#seccodeimg,#fresh").click(function(){
		$("#seccodeimg").attr("src","../youngth/common/seccode.php?"+Math.random());
		$("#seccode").focus();
	}); 
		});
  </script>
	<div class="classhead"><a href="./" style="">首页</a> >> 在线投稿系统 </div>

	<div class="classcontent" style="width:690px;float:left;margin-top:20px">	
<form name="form" method="post" action="" id="xform">
<table width="100%" border="0" cellpadding="1" cellspacing="1" bgcolor="#ffffff">
  <tr>
    <td width="30%" align="right">投放栏目：</td>
    <td width="70%">
	<select name="sort" id="sort">
	<option value="">== 请选择投放栏目 ==</option> 
	  <?=listoperatecat(ANY_ROOTCOLUMN,'0','categories',$catearr);?>
	  </select><span id="sort_err"></span></td>
  </tr>
  <tr>
    <td align="right">文章标题：</td>
    <td><input name="title" value="<?=$_COOKIE['ctitle']?>" type="text" id="etitle" size="30" maxlength="250"><span id="etitle_err"></span></td>
  </tr>
  <tr>
    <td align="right">记者/作者：</td>
    <td><input name="author" type="text" id="author" size="30" maxlength="200"><span id="author_err"></span></td>
  </tr>
  <tr>
    <td align="right">文章来源：</td>
    <td><input name="source" type="text" id="source" size="30" maxlength="200"><span id="source_err"></span></td>
  </tr>
<!--   <tr>
    <td align="right">您的地址：</td>
    <td><input name="adds" type="text" id="adds" size="30" maxlength="200"></td>
  </tr>
  <tr>
    <td align="right">您的电话：</td>
    <td><input name="tel" type="text" id="tel" size="30" maxlength="200"></td>
  </tr>
  <tr>
    <td align="right">您的邮箱：</td>
    <td><input name="email" type="text" id="email" size="30" maxlength="200"></td>
  </tr> -->
  <tr>
    <td align="right" width="30%">详细内容：</td>
    <td width="70%">
    <textarea id="content_editor" name="content" style="width:600px;height:300px;visibility:hidden;">
<style type="text/css">
#note p {color:#ccc;}
</style>
	<div id = "note" style = "">
		<p style="font-weight:bold;">一些说明：：：</p>
		<p>最好是利用、推荐用后台传图片。传文章没问题。</p>
		<p>请不要用该投稿页投以下栏目，否则会出现图片无法显示的问题：</p>
		<p>青年动态：图片新闻、先锋专访、青年视角、镜头民大</p>
		<p>青年课堂：图说故事</p>
		<p>青年资讯：青春纪念册、音乐速递、新碟上架</p>
	</div>
	</textarea>
	</td>
	</tr>
 <tr>
    <td align="right">验证码:</td>
    <td>
          <input name="seccode" type="text" id="seccode" size="4" maxlength="4"/>
          <img src="../youngth/common/seccode.php" alt="看不清楚?点击刷新" align="absmiddle" id="seccodeimg"/><span id="seccode_err"></span></td>
  </tr>
    <tr>
    <td align="right">&nbsp;</td>
    <td><span class="tip">Tip2:若文章需要上传图片，请在校园网内访问该投稿页面。</span></td>
  </tr>
  <tr>
    <td align="right">&nbsp;</td>
    <td><input class="btn" type="submit" name="submit" onclick="return confirm('确认您已经对刚编辑过的文章进行了备份？');" value="提交"></td>
  </tr>
</table>
</form>		

</div>
</div>

<script type="text/javascript" src="../youngth/common/js/xform.js"></script>
<script type="text/javascript" src="../youngth/common/js/reg.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$.setErrMsg({require:'&nbsp;#name#不能为空！'});
	$('#xform').xForm(
		{'email':'require|validEmail','check':'validCheck','seccode':'require','source':'require','truename':'require|validChn','phone':'require|validNum','name':'require','sort':'require','etitle':'require','author':'require'},

		{'email':'邮箱','check':'用户协议','seccode':'验证码','source':'文章来源','truename':'真实姓名','phone':'电话号码','name':'名称','etitle':'文章标题','author':'文章作者','sort':'投稿栏目'}
	);
});
</script>
    
    <div class="clear"></div>

    <?php
	include ("footer.php");

	?>
